package captchax

import (
	"gitee.com/workits/pkgs/cachex"
	"github.com/jinzhu/copier"
	"github.com/mojocn/base64Captcha"
)

var DigitCaptcha *base64Captcha.Captcha

// InitDigitEngine 初始化base64Captcha.Captcha(数字类型)
func InitDigitEngine(cfg Config, cache cachex.Cache) {
	if DigitCaptcha != nil {
		return
	}

	// 初始化驱动
	driver := new(base64Captcha.DriverDigit)
	if err := copier.Copy(driver, cfg); err != nil {
		panic(err)
	}
	DigitCaptcha = base64Captcha.NewCaptcha(driver, NewStore(cfg, cache))
}
